package com.zlcx.tz.live.domain.backup;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.zlcx.tz.live.domain.LiveRoomJoinRecord;
import com.zlcx.tz.live.utils.DozerMapper;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.Date;

/**
 * <p>加入房间记录</p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author zl
 * @version 1.0
 * @date Created in 2019/4/18 10:10
 * @copyright: Copyright (c) founders
 */

@Data
@Entity(name = "live_room_join_record_backup")
@JsonSerialize
@DynamicUpdate
@DynamicInsert
public class LiveRoomJoinRecordBackUpDO {

    @Id
    private Long id;
    /**
     * 房间id
     */
    private Long roomId;
    /**
     * 用户id
     */
    private Long userId;
    /**
     * 麦状态 0-禁麦，1-正常
     */
    private Integer userMicState;
    /**
     * 自己麦状态
     */
    private Integer userSelfMicState;
    /**
     * 用户在房间中的角色身份
     *
     * @see com.zlcx.tz.live.enums.RoomUserRole
     */
    private Integer userRole;
    /**
     * 用户加入房间时间
     */
    private Date enterTime;
    /**
     * 用户离开房间时间
     */
    private Date leaveTime;
    /**
     * 用户在房间中的状态
     *
     * @see com.zlcx.tz.live.enums.RoomJoinStatus
     */
    private Integer joinState;

    private Date createTime;

    private Date updateTime;
    /**
     * 房间中的用户身份变更时，记录的时间
     */
    private Date roleChangeTime;

    public static LiveRoomJoinRecordBackUpDO from(LiveRoomJoinRecord joinRecord){
        LiveRoomJoinRecordBackUpDO joinRecordBackup = new LiveRoomJoinRecordBackUpDO();
        DozerMapper.getInstance().map(joinRecord, joinRecordBackup);
        return joinRecordBackup;
    }

}